<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body table-tool-mini">
            <div class="layui-form toolbar" id="tbToolBar">
                <div class="layui-form-item">
					<div class="layui-inline">
						<span style="color:red;">删除操作只是移出上传的KML文件，并不会清除入库数据！！！</span>
					</div>                
                    <div class="layui-inline" style="float: right;margin-right: 0px;">
						<div class="layui-inline" style="padding-right: 0px;margin-right: 0px;">
							<label class="layui-form-label w-auto">场景</label>
							<div class="layui-input-inline mr0">
								<input name="name" class="layui-input" type="text" placeholder="请输入场景名称"/>
							</div>
						</div>
						<div class="layui-inline" style="padding-right: 0px;margin-right: 0px;">
							<button class="layui-btn icon-btn" lay-filter="formSubSearchBizKml" lay-submit>
								<i class="layui-icon">&#xe615;</i>查询
							</button>
						</div>					
					</div>
				</div>
				<table class="layui-table" id="tableBizKml" lay-filter="tableBizKml"></table>
			</div>
		</div>
	</div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="tableBarBizKml">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<!-- 表格状态列 -->
<script type="text/html" id="tableStateBizKml">
#[[  {{# if(d.status == '0'){ }}
    	<span style="color: #23aa2e;">上传成功</span>
     {{# }  else if(d.status == '1'){ }}
		<span style="color: #23aa2e;">入库中</span>
  	 {{# }  else if(d.status == '2'){ }}
		<span style="color: #23aa2e;">完成</span>
  	 {{# } else if(d.status == '3'){ }}
		<span style="color: #ff0000;">入库失败</span>
  	 {{# } else { }}
		<span style="color: #ff0000;">未知异常</span>
  	 {{# } }}
]]#
</script>



<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'util', 'admin', 'config'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;
        var config = layui.config;
        form.render('select');
        // 渲染表格
        var insTb = table.render({
            elem: '#tableBizKml',
            url: '#(ctx)/biz/kml/listData', 
            page: true,
            toolbar: false,
            cols: [[
                {type: 'numbers', title: '序号'},
                {field: 'sceneName', sort: false, title: '场景'},
                {field: 'name', sort: false, title: '文件'},
				{field: 'createUserName', sort: false, title: '来源于'},
                {
                    field: 'createTime', sort: false, templet: function (d) {
                        return util.toDateString(d.createTime);
                    }, title: '创建时间'
                },				
				{field: 'status', sort: false, templet: '#tableStateBizKml', title: '状态', align: 'center'},
				{field: 'remark', sort: false, title: '备注'},
                {align: 'left', toolbar: '#tableBarBizKml', title: '操作', fixed: 'right',width: 170}
            ]],
        });

        // 搜索
        form.on('submit(formSubSearchBizKml)', function (data) {
            insTb.reload({where: data.field}, 'data');
        });

        // 工具条点击事件
        table.on('tool(tableBizKml)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'del') { 
                doDel(data.id, data.name);
            } else if (layEvent === 'view') { 
            }
        });

        // 删除
        function doDel(id, name) {
        	layer.confirm('确定要删除“【<span style="color:red;">' + name + '</span>】”吗？', {
                skin: 'layui-layer-admin',
                shade: .1
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('biz/kml/delete', {
                    id: id
                }, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.message, {icon: 1});
                        insTb.reload({}, 'data');
                    } else {
                        layer.msg(res.message, {icon: 2});
                    }
                }, 'get');
            });
        }



    });
</script>
